package com.michael.demos.ddd.springboot.domains;

import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Value;

import java.time.LocalDateTime;

/**
 * 在账户之间的资金转移活动
 */
@Value
@RequiredArgsConstructor
public class Activity {

    @Getter
    private ActivityId id;

    /**
     * 活动对应的账户
     */
    @Getter
    @NonNull
    private final Account.AccountId ownerAccountId;

    /**
     * 出账方账户
     */
    @Getter
    @NonNull
    private final Account.AccountId sourceAccountId;

    /**
     * 入账方账户
     */
    @Getter
    @NonNull
    private final Account.AccountId targetAccountId;

    /**
     * 活动时间
     */
    @Getter
    @NonNull
    private final LocalDateTime timestamp;

    /**
     * 转移的金额
     */
    @Getter
    @NonNull
    private final Money money;

    public Activity(
            @NonNull Account.AccountId ownerAccountId,
            @NonNull Account.AccountId sourceAccountId,
            @NonNull Account.AccountId targetAccountId,
            @NonNull LocalDateTime timestamp,
            @NonNull Money money
    ) {
        this.id = null;
        this.ownerAccountId = ownerAccountId;
        this.sourceAccountId = sourceAccountId;
        this.targetAccountId = targetAccountId;
        this.timestamp = timestamp;
        this.money = money;
    }

    @Value
    public static class ActivityId {
        private final Long value;
    }
}
